package chapter;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;

import org.junit.Test;

/**
 * description: new java files...TODO
 * @version v1.0
 * @author w
 * @date 2018年8月3日下午10:35:19
 *
 */

public class Default {

	@Test
	public void te() {
		System.out.println((char)90);
		System.out.println((int)'A');
	}
	
	@Test
	public void gen() {
		int hang = 26 ;
		int lie = 15 ;
		for (int x = 1 ; x<= hang ; x++) {
			for (int y=1; y <= lie ;y++) {
				System.out.print((char)(64+x) +""+y +"\t");
			}
			System.out.println("第："+x+"=========完毕");
		}
	}
	
	@Test
	public void gen2() {
		int hang = 26 ;
		int lie = 20 ;
		// 每一行有多少列,动态变化的 
		Map<Integer, Integer> map = initMap(26 , 10);
		
  		for (int x = 1 ; x<= hang ; x++) {
			for (int y=1; y <= map.get(x) ;y++) {
				System.out.print((char)(64+x) +""+y +"\t");
			}
			System.out.println("第："+x+"=========完毕");
		}
	}

	private Map<Integer ,Integer> initMap(int hang , int lie) {
		Map<Integer ,Integer> map = new HashMap<>();
		for (int i = 1; i <= hang ; i++) {
			int nextInt = nextInt(1, lie);
			System.out.println(i +" --- nextInt: "+ nextInt);
			map.put(i, nextInt);
		}
		return map ;
	}
	
	/**
	 * @param 获取一定范围的随机数
	 * @return
	 */
	@Test
	public void nextInt() {
        int nextInt = ThreadLocalRandom.current().nextInt(0 , 10);
        System.out.println(nextInt);
        System.out.println(nextInt(0 , 10));
	}
	
	/**
	 * @param min  最小值
	 * @param max  最大值
	 * @return
	 */
	public int nextInt(int min , int max) {
        int nextInt = ThreadLocalRandom.current().nextInt(min , max);
        return nextInt;
	}
}
